<template>
  <view class="card">
    <view class="w-276">
      <u-image width="276rpx" height="216rpx" radius="12rpx" :src="info.logo"></u-image>
    </view>
    <view class="ml-24 h-216 flex-column flex-row-between" style="flex: 1">
      <view>
        <view class="flex-row-between">
          <view>
            <u--text :text="info.title || ''" :lines="1" size="32rpx" bold></u--text>
          </view>
          <text class="fs-28 c-ff0000">{{ info.status | status_text }}</text>
        </view>
        <view class="flex-column-center mt-16 mb-28">
          <image class="w-22 h-28 mr-8" src="/static/marker-icon.png"></image>
          <text class="fs-24 c-677585">{{ info.region_name || '' }}</text>
        </view>
      </view>
      <view class="flex-between-center" style="justify-content: flex-end; margin-left: -20rpx">
        <u-button text="查看资料" color="#C5261D" :customStyle="btnStyle"
          @click="$utils.to(`/pages2/my/charge_store_detail?id=${info.id}`)">
        </u-button>
        <block v-if="info.status == '0'">
          <view class="w-16"></view>
          <u-button text="驳回申请" color="#C5261D" :customStyle="btnStyle" @click="onReject"></u-button>
          <view class="w-16"></view>
          <u-button text="通过" color="#C5261D" :customStyle="btnStyle" @click="onPass"></u-button>
        </block>
      </view>
    </view>
    <!-- 驳回弹窗 -->
    <RejectStorePop ref="rejectStorePopRef" @submit="onRejectSubmit" />
  </view>
</template>
<script>
import RejectStorePop from "./RejectStorePop.vue";
import { xhManageYanShopAuditApi } from "@/services/my";
export default {
  data() {
    return {
      btnStyle: {
        backgroundColor: "transparent",
        width: "124rpx",
        height: "56rpx",
        color: "#C5261D",
        borderRadius: "8rpx",
        fontSize: "24rpx",
        padding: 0,
        whiteSpace: "nowrap",
      },
    };
  },
  filters: {
    status_text(value) {
      if (value == 'all') {
        return '全部';
      } else if (value == '0') {
        return '待审核';
      } else if (value == '1') {
        return '已入驻';
      } else if (value == '2') {
        return '已驳回';
      }
    },
  },
  props: {
    info: {
      type: Object,
      default: () => { },
    },
  },
  components: {
    RejectStorePop,
  },
  methods: {
    onReject() {
      this.$refs.rejectStorePopRef.open();
    },
    onRejectSubmit(content) {
      xhManageYanShopAuditApi({
        shop_id: this.info.id,
        status: 2,
        audit_remark: content,
      }).then(() => {
        this.$utils.toast("驳回成功");
        this.$emit("reload");
      });
    },
    onPass() {
      uni.showModal({
        title: "通过提示",
        content: "确定要通过烟酒店的入驻申请吗？",
        success: (res) => {
          if (res.confirm) {
            xhManageYanShopAuditApi({
              shop_id: this.info.id,
              status: 1,
            }).then((res) => {
              this.$utils.toast("审核通过");
              this.$emit("reload");
            });
          }
        },
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.card {
  width: 100%;
  display: flex;
  align-items: center;
}
</style>